package blog.service.impl.back;

import blog.dao.back.ConsumerBackMapper;
import blog.entity.Consumer;
import blog.service.back.ConsumerBackService;
import blog.vo.back.*;
import blog.vo.common.PaginationVO;
import cn.hutool.core.bean.BeanUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 　　* @description: TODO
 * 　　* @param
 * 　　* @return
 * 　　* @throws
 * 　　* @author Administrator
 * 　　* @date $ $
 *
 */
@Service
public class ConsumerBackServiceImpl implements ConsumerBackService {
    @Autowired
    private ConsumerBackMapper consumerBackMapper;

    @Override
    public Consumer emailLogin(EmailLoginVO emailLoginVO) {
        Consumer consumer = BeanUtil.copyProperties(emailLoginVO, Consumer.class);
        return consumerBackMapper.emailLogin(consumer);
    }

    @Override
    public Consumer phoneNumberLogin(PhoneNumberLoginVO phoneNumberLoginVO) {
        Consumer consumer = BeanUtil.copyProperties(phoneNumberLoginVO, Consumer.class);
        return consumerBackMapper.phoneNumberLogin(consumer);
    }

    @Override
    public List<Consumer> byConsumerRootGetConsumerInfo(ByConsumerRootGetConsumerInfoVO byConsumerRootGetConsumerInfoVO) {
        return consumerBackMapper.byConsumerRootGetConsumerInfo(byConsumerRootGetConsumerInfoVO);
    }

    @Override
    public List<Consumer> byConsumerRootAndConsumerStatusGetConsumerInfo(ByConsumerRootAndConsumerStatusGetConsumerInfoVO byConsumerRootAndConsumerStatusGetConsumerInfoVO) {
        return consumerBackMapper.byConsumerRootAndConsumerStatusGetConsumerInfo(byConsumerRootAndConsumerStatusGetConsumerInfoVO);
    }

    @Override
    public List<Consumer> getAllConsumer(PaginationVO paginationVO) {
        return consumerBackMapper.getAllConsumer(paginationVO.getPageNum(),paginationVO.getPageSize());
    }

    @Override
    public List<Consumer> byConsumerNameGetConsumerInfo(ByConsumerNameGetConsumerInfoVO byConsumerNameGetConsumerInfoVO) {
        return consumerBackMapper.byConsumerNameGetConsumerInfo(byConsumerNameGetConsumerInfoVO);
    }

    @Override
    public Consumer byConsumerUuidGetConsumerInfo(ByConsumerUuidGetConsumerInfoVO byConsumerUuidGetConsumerInfoVO) {
        return consumerBackMapper.byConsumerUuidGetConsumerInfo(byConsumerUuidGetConsumerInfoVO.getConsumerUuid());
    }

    @Override
    public int updateConsumerInfo(UpdateConsumerInfoVO updateConsumerInfoVO) {
        Consumer consumer = BeanUtil.copyProperties(updateConsumerInfoVO, Consumer.class);
        return consumerBackMapper.updateConsumerInfo(consumer);
    }

    @Override
    public int updateConsumerHeadPortrait(UpdateConsumerHeadPortraitVO updateConsumerHeadPortraitVO) {
        return consumerBackMapper.updateConsumerHeadPortrait(updateConsumerHeadPortraitVO.getConsumerUuid(),updateConsumerHeadPortraitVO.getConsumerHeadPortrait());
    }

    @Override
    public int addRootConsumer(AddRootConsumerVO addRootConsumerVO) {
        Consumer consumer = BeanUtil.copyProperties(addRootConsumerVO, Consumer.class);
        return consumerBackMapper.addRootConsumer(consumer);
    }

}
